package com.chaosj.tools.rules

import com.chaosj.tools.StockDiscoverTools

/**
 * 涨停后连续跌2天，并且今天开盘竞价低开在2个点以内
 */
class LimitRule implements IAbnormalRule {

    @Override
    boolean execute(String stockName, List<StockDiscoverTools.DescriptionStock> stocks) {
        int index = stocks.size()-1
        if( stocks.get(index-2).dailyLimit() &&
            stocks.get(index-1).todayUp()<= 0.92 &&
            stocks.get(index).todayUp()<= 0.94 &&
            stocks.get(index).todayUp() >= 0.98
        ){
            println(description(stockName,(1- stocks.get(index).todayUp()))+"")
            return true
        }
        return false
    }

    @Override
    boolean support(String stockName, List<StockDiscoverTools.DescriptionStock> stocks) {
        return stocks.size()>=3
    }

    @Override
    String description(Object... desc) {
        return String.format("【%s】涨停后连续两天大跌,今天开盘跌幅小于%s个点",desc)
    }
}
